package com.gqzdev.xblog.service.impl;

import com.gqzdev.xblog.entity.Ad;
import com.gqzdev.xblog.dao.AdDao;
import com.gqzdev.xblog.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Ad)表服务实现类
 *
 * @author ganquanzhong
 * @since 2020-05-31 21:08:54
 */
@Service
public class AdServiceImpl implements AdService {
    @Autowired
    private AdDao adDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Ad queryById(Integer id) {
        return this.adDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Ad> queryAllByLimit(int offset, int limit) {
        return this.adDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ad 实例对象
     * @return 实例对象
     */
    @Override
    public Ad insert(Ad ad) {
        this.adDao.insert(ad);
        return ad;
    }

    /**
     * 修改数据
     *
     * @param ad 实例对象
     * @return 实例对象
     */
    @Override
    public Ad update(Ad ad) {
        this.adDao.update(ad);
        return this.queryById(ad.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.adDao.deleteById(id) > 0;
    }


    @Override
    public List<Ad> findList(Map<String, Object> queryMap) {
        return this.adDao.findList(queryMap);
    }

    @Override
    public List<Ad> findListShow(Map<String, Object> queryMap) {
        return this.adDao.findListShow(queryMap);
    }

    @Override
    public int getTotal(Map<String, Object> queryMap) {
        return adDao.getTotal(queryMap);
    }

    @Override
    public int delete(String ids) {
        return adDao.delete(ids);
    }

    @Override
    public int check(String ids) {
        return adDao.check(ids);
    }
}